package org.example.travel_web.controller.user;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.example.travel_web.dto.login.ForgetReq;
import org.example.travel_web.dto.login.LoginReq;
import org.example.travel_web.dto.login.LoginResult;
import org.example.travel_web.dto.login.RegisterReq;
import org.example.travel_web.service.UserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/login")
@Tag(name = "用户登录")
public class UserLoginController {

    @Resource
    private UserService userService;

    @PostMapping
    @Operation(summary = "用户登录")
    public LoginResult login(@Valid LoginReq req) {
        return userService.login(req);
    }

    @PostMapping("/register")
    @Operation(summary = "用户注册")
    public void register(@Valid RegisterReq req) {
        userService.register(req);
    }

    @PostMapping("/forget")
    @Operation(summary = "忘记密码")
    public void forget(@Valid ForgetReq req) {
        userService.forget(req);
    }
}
